
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.soldier.dto.SoldierOuterLoginAccountDTO;
import com.insigma.business.qrcode.soldier.entity.SoldierOuterLoginAccountDO;
import com.insigma.business.qrcode.soldier.request.SoldierOuterLoginAccountBSearcher;
import com.insigma.business.qrcode.soldier.request.SoldierOuterLoginAccountInsertRequest;
import com.insigma.business.qrcode.soldier.request.SoldierOuterLoginAccountSearchRequest;
import com.insigma.business.qrcode.soldier.request.SoldierOuterLoginAccountUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class SoldierOuterLoginAccountProviderConverter extends AbstractConverter<SoldierOuterLoginAccountDTO, SoldierOuterLoginAccountDO> {

    private final static SoldierOuterLoginAccountProviderConverter soldierOuterLoginAccountConverter = new SoldierOuterLoginAccountProviderConverter();

    private SoldierOuterLoginAccountProviderConverter(){}

    
    public static SoldierOuterLoginAccountBSearcher convertRequestSO2Searcher(final SoldierOuterLoginAccountSearchRequest request){
        final SoldierOuterLoginAccountBSearcher soldierOuterLoginAccountBSearcher = new SoldierOuterLoginAccountBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,soldierOuterLoginAccountBSearcher);
        return soldierOuterLoginAccountBSearcher;
    }

    
    public static SoldierOuterLoginAccountDO convertRequestUO2DO(final SoldierOuterLoginAccountUpdateRequest soldierOuterLoginAccountUpdateRequest) {
        final SoldierOuterLoginAccountDO soldierOuterLoginAccountDO = new SoldierOuterLoginAccountDO();
        BeanUtils.copyProperties(soldierOuterLoginAccountUpdateRequest,soldierOuterLoginAccountDO);
        
        return soldierOuterLoginAccountDO;
    }

    
    public static SoldierOuterLoginAccountDO convertRequestIO2DO(final SoldierOuterLoginAccountInsertRequest soldierOuterLoginAccountInsertRequest) {
        final SoldierOuterLoginAccountDO soldierOuterLoginAccountDO = new SoldierOuterLoginAccountDO();
        BeanUtils.copyProperties(soldierOuterLoginAccountInsertRequest,soldierOuterLoginAccountDO);
        return soldierOuterLoginAccountDO;
    }

    
    public static List<SoldierOuterLoginAccountDTO> convertResponseDOList2DTOList(final List<SoldierOuterLoginAccountDO> soldierOuterLoginAccountDOList){
        return soldierOuterLoginAccountConverter.convertGenericResponseDOList2DTOList(soldierOuterLoginAccountDOList);
    }

    
    public static SoldierOuterLoginAccountDTO convertResponseDO2DTO(final SoldierOuterLoginAccountDO soldierOuterLoginAccountDO){
        return soldierOuterLoginAccountConverter.convertGenericResponseDO2DTO(soldierOuterLoginAccountDO);
    }

    
    @Override
    protected SoldierOuterLoginAccountDTO doConvertResponseDO2DTO(SoldierOuterLoginAccountDO soldierOuterLoginAccountDO) {
        final SoldierOuterLoginAccountDTO soldierOuterLoginAccountDTO = new SoldierOuterLoginAccountDTO();
        try {
            BeanUtils.copyProperties(soldierOuterLoginAccountDO, soldierOuterLoginAccountDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return soldierOuterLoginAccountDTO;
    }

}
